﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReWhiteBroadDetailDAL : SyncBase<Model.ReWhiteBroadDetail>
    {
        static ReWhiteBroadDetailDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReWhiteBroadDetailDAL.addSQL = @"	insert into TempReWhiteBroadDetail(
	TeacherID,LessionID,BroadBatch,StudentID,StudentName,AnswerType,Answer,Croute,CIp,Cport,AnswerName,SendTime,SendPiont)
	values (
	@TeacherID,@LessionID,@BroadBatch,@StudentID,@StudentName,@AnswerType,@Answer,@Croute,@CIp,@Cport,@AnswerName,@SendTime,@SendPiont)";
            ReWhiteBroadDetailDAL.tbName = "TempReWhiteBroadDetail";
            ReWhiteBroadDetailDAL.remoteUrl = "/Ayyfford/AddReWhiteBroadDetail";
            ReWhiteBroadDetailDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}),",
                                          t.TeacherID.NullNumber(), t.LessionID.NullNumber(), t.BroadBatch.NullNumber(), t.StudentID.NullNumber(), t.StudentName.NullString(), t.AnswerType.NullNumber(), t.Answer.NullString(), t.Croute.NullString(), t.CIp.NullString(), t.Cport.NullString(), t.AnswerName.NullString(), t.SendTime.NullDate(), t.SendPiont.NullNumber());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReWhiteBroadDetail t)
        {
            SyncBase<Model.ReWhiteBroadDetail>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReWhiteBroadDetail>.AsyncData();
        }
    }
}
